import matplotlib.pyplot as plt
import numpy as np

from matplotlib import gridspec
from matplotlib import rcParams
rcParams['font.family'] = 'times new roman'
rcParams['font.size'] = 14
	


if __name__ == '__main__':
	plt.figure(1, figsize=(6,3.5), dpi=80)
	ax = plt.axes()

	#---
	cdf_x = []
	cdf_y = []
	with open("DCTCP_CDF.txt", 'r') as file:
	    for line in file.readlines():
	    	split = line.split()
	    	print split
	    	cdf_x.append(float(split[0]))
	    	cdf_y.append(float(split[-1]))

	plt.semilogx(cdf_x, cdf_y,'r', linewidth=1.5)

	# plot the CDF
	fs = 14
	plt.xlabel('Flow Size(Bytes)', fontsize=fs)
	plt.ylabel('CDF', fontsize=fs)
	#plt.xlim(0,10000000000)
	plt.ylim(0.2,1)
	plt.legend(('web search', 'data mining'),loc=0, fontsize=fs)
	ax.yaxis.grid(zorder=0, ls='--')

	#---
	cdf_x = []
	cdf_y = []
	with open("VL2_CDF.txt", 'r') as file:
	    for line in file.readlines():
	    	split = line.split()
	    	print split
	    	cdf_x.append(float(split[0]))
	    	cdf_y.append(float(split[-1]))

	plt.semilogx(cdf_x, cdf_y,'b', linewidth=1.5)

	# plot the CDF
	fs = 14
	plt.xlabel('Flow Size(Bytes)', fontsize=fs)
	plt.ylabel('CDF', fontsize=fs)
	#plt.xlim(0,10000000000)
	plt.ylim(0.2,1)
	plt.legend(('web search', 'data mining'),loc=0, fontsize=fs)
	ax.yaxis.grid(zorder=0, ls='--')

	plt.subplots_adjust(bottom=0.18, top=0.92, left=0.12, right=0.95)
	plt.show()
